package com.doctcloud.hisinfo.histable.domain.comm;

import com.doctcloud.common.core.annotation.Excel;
import com.doctcloud.common.core.annotation.TableDesc;
import lombok.*;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;

import static com.doctcloud.common.core.utils.StringUtils.trim;

@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(of = {"prescType"})
@ToString
@TableDesc("药品处方分类字典")
public class PrescTypeDictDo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Excel(name = "序号")
    private Integer serialNo;
    @Excel(name = "处方类型")
    @NotBlank(message = "处方类型不得为空")
    private String prescType;
    @Excel(name = "处方简写")
    @NotBlank(message = "处方简写不得为空")
    private String curtName;
    @Excel(name = "是否使用账册管理", readConverterExp = "1=适用,0=不适用")
    private Integer toxicAcct;
    @Data
    public static class primaryKey {
        private final String prescType;
        public primaryKey(String prescType) {
            this.prescType = prescType;
        }
    }

    public void setPrescType(String prescType) {
        this.prescType = trim(prescType);
    }

    public void setCurtName(String curtName) {
        this.curtName = trim(curtName);
    }

    public void setToxicAcct(Integer toxicAcct) {
        this.toxicAcct = toxicAcct == null ? 0:toxicAcct;
    }
}
